{% extends "pretixpresale/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load rich_text %}
{% block title %}{% trans "Modify order" %}{% endblock %}
{% block content %}
    <h2>
        {% blocktrans trimmed with code=order.code %}
            Change order: {{ code }}
        {% endblocktrans %}
    </h2>
    <form method="post" href="">
        {% csrf_token %}
        {% for position, positions in formgroups.items %}
            <div class="panel panel-default items">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <strong>{{ position.item }}</strong>
                        {% if position.variation %}
                            – {{ position.variation }}
                        {% endif %}
                    </h3>
                </div>
                <div class="panel-body">
                    <div class="form-order-change form-horizontal">
                        {% if position.subevent %}
                            <div class="form-group">
                                <label class="col-md-3 control-label">
                                    {% trans "Date" context "subevent" %}
                                </label>
                                <div class="col-md-9 form-control-text">
                                    <ul class="addon-list">
                                        {{ pos.subevent.name }} &middot; {{ pos.subevent.get_date_range_display }}
                                        {% if pos.event.settings.show_times %}
                                            <span class="fa fa-clock-o" aria-hidden="true"></span>
                                            {{ pos.subevent.date_from|date:"TIME_FORMAT" }}
                                        {% endif %}
                                    </ul>
                                </div>
                            </div>
                        {% endif %}

                        {% for p in positions %}
                            {% if p.pk != position.pk %}
                                {# Add-Ons #}
                                <legend>+ {{ p.item.name }}{% if p.variation %} – {{ p.variation.value }}{% endif %}</legend>
                            {% endif %}
                            {% if p.attendee_name %}
                                <div class="form-group">
                                    <label class="col-md-3 control-label">
                                        {% trans "Attendee name" %}
                                    </label>
                                    <div class="col-md-9 form-control-text">
                                        {{ p.attendee_name }}
                                    </div>
                                </div>
                            {% endif %}
                            {% bootstrap_form p.form layout="checkout" %}
                        {% endfor %}
                    </div>
                </div>
            </div>
        {% endfor %}

        <div class="row checkout-button-row">
            <div class="col-md-4">
                <a class="btn btn-block btn-default btn-lg"
                        href="{{ view.get_order_url }}">
                    {% trans "Cancel" %}
                </a>
            </div>
            <div class="col-md-4 col-md-offset-4">
                <button class="btn btn-block btn-primary btn-lg" type="submit">
                    {% trans "Save changes" %}
                </button>
            </div>
            <div class="clearfix"></div>
        </div>
    </form>
{% endblock %}
